package com.acme.task1;

public class Calculator {
	
	/**
	 * Method makes calculation according to given input
	 * @param args in the form {doubleOperand1, charOperation, doubleOperand2}
	 * @return result of calculation
	 */
	public double getOperationResult(String[] args) {
		if (args.length < 3) {
			throw new IllegalArgumentException("Not enough arguments");
		}
		
		double operand1 = 0;
		double operand2 = 0;
		operand1 = Double.parseDouble(args[0]);
		operand2 = Double.parseDouble(args[2]);

		char operation = args[1].charAt(0);
		double result = 0.d;
		switch (operation) {
		case '*':
			result = operand1 * operand2;
			break;
		case '/':
			result = operand1 / operand2;
			break;
		case '+':
			result = operand1 + operand2;
			break;
		case '-':
			result = operand1 - operand2;
			break;
		default:
			throw new IllegalArgumentException("Operation is not valid");
		}
		return result;
	}
	
	public static void main(String[] args) {
		Calculator calc = new Calculator();
		System.out.println(calc.getOperationResult(args));
	}
}
